<template>
  <div class="constentmain">
    <list-table-new v-bind="tableSetting" ref="klTable"></list-table-new>
  </div>
</template>
<script>
import {
  queryClassPlanList,
} from "@/api/operationManagement/runningSchedule.js";
export default {
  props: {
    searchData: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      currentRowId: "",
      tableSetting: {
        radioShow: true,
        showFilterBtn: false,
        showCustomBtn: false,
        searchObj: {
          searchMethod: (params, sortStr) => {
            this.getTableData(params, sortStr);
          },
          queryData: {
            page: 1,
            pageSize: 15,
          },
          searchArr: [
            {
              type: "organization",
              label: "值班单位",
              model: "deptName",
              idsStr: "deptId",
            },
            {
              type: "input",
              label: "方案名称",
              model: "name",
              placeholder: "请输入方案名称",
            },
          ],
        },
        //过滤器的值
        filterFormData: {},
        //过滤器的默认值
        defaultFilterData: {},
        userCustomData: [],
        actionList: [],
        tableMethods: {
          //点击行的方法
          rowClick: (row) => {
            this.$refs.klTable.radioSelect(row);
          },
        },
        column: [
          {
            label: "值班单位",
            prop: "deptName",
            sortable: "custom",
          },
          {
            label: "方案名称",
            prop: "name",
            sortable: "custom",
          },
          {
            label: "值班人员类型",
            prop: "staffType",
            sortable: "custom",
            formatter: (row) => {
              return this.$store.getters.fineDirtDataName(
                "operation_staff_type",
                row.staffType
              );
            },
          },
          
          {
            label: "创建时间",
            prop: "createTime",
            sortable: "custom",
          },
        ],
      },
    };
  },
  created(){
    this.tableSetting.searchObj.queryData = Object.assign(
      this.tableSetting.searchObj.queryData,
      this.searchData
    );
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.$refs.klTable.searchData();
    },
    //获取列表数据
    getTableData(params, sortStr) {
      let queryData = Object.assign({}, params);
      if (sortStr.length > 0) {
        queryData.orders = sortStr;
      }
      queryClassPlanList(queryData).then((res) => {
        this.$set(this.tableSetting, "tableData", res.data.list);
        this.$set(this.tableSetting, "totalNumber", res.data.total);
      });
    },
    //获取选中数据
    getselectData() {
      let data = this.$refs.klTable.getRadioData();
      return data;
    },
  },
};
</script>
<style lang="less" scoped>
.constentmain {
  width: 100%;
  height: 100%;
}
</style>